﻿using NFine.Application.BusinessManage;
using NFine.Code;
using NFine.Domain.Entity.BusinessManage;
using NFine.Domain.ViewModel.QueryDto;
using System.Web;
using System.Web.Mvc;

namespace NFine.Web.Areas.BusinessManage.Controllers
{
    public class D_MemberChargeController : ControllerBase
    {
        private D_MemberChargeApp memberChargeApp = new D_MemberChargeApp();
        private readonly D_SalaryHistoryApp salaryHistoryApp = new D_SalaryHistoryApp();

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = memberChargeApp.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }


        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGrid(string keyword)
        {
            var data = memberChargeApp.GetGrid(keyword);
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyword)
        {
            var data = memberChargeApp.GetForm(keyword);
            return Content(data.ToJson());
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public ActionResult SubmitForm(D_MemberCharge memberChargeEntity, string keyValue)
        {
            memberChargeApp.SubmitForm(memberChargeEntity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            memberChargeApp.DeleteForm(keyValue);
            return Success("删除成功。");
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetAllSaleGrid(Pagination pagination, SearchInputDto searchInput)
        {
            var lst = salaryHistoryApp.GetSalaryHistoryList(pagination, searchInput);
            var data = new
            {
                rows = lst,
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetAllsSaleGrid(Pagination pagination, string pData)
        {
            if(string.IsNullOrEmpty(pData))
                pData = "{\"Account\":\"\",\"AccountName\":\"\",\"ChangeType\":\"用户充值\"}";
            var data = new
            {
                rows = memberChargeApp.GetAllsSaleGrid(pagination, pData),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        
    }
}
